<!DOCTYPE html>
<br lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .con {
            display: none;
            position: relative;
            width: 177px;
            height: 35px;
            border: 1px solid #ccc;
            color: #333;
            line-height: 35px;
            box-shadow: 0px -20px 24px -30px inset #000
        }

        .con::before {
            content: '';
            width: 0;
            height: 0;
            position: absolute;
            top: 28px;
            left: 18px;
            border: 8px solid #000;
            border-style: solid dashed dashed;
            border-color: #fff transparent transparent;

        }
    </style>

</head>

<div class="search">
    <div class="con">123</div>
    <input type="text" class="jd_input" placeholder="请输入要查询的快递号">
</div>


<script>

    var con = document.querySelector('.con')
    var ipt = document.querySelector('input')
    ipt.addEventListener('keyup', function () {
        if (this.value == '') {
            con.style.display = 'none'
        } else {
            con.style.display = 'block'
            con.innerHTML = this.value
        }
    })
    ipt.addEventListener('focus', function () {
        if (this.value !== '') {
            con.style.display = 'block'
            con.innerHTML = this.value
        } else {
            con.style.display = 'none'
        }
    })
    ipt.addEventListener('blur', function () {
        con.style.display = 'none'
    })

























    // var con = document.querySelector('.con')
    // var jd_input = document.querySelector('.jd_input')
    // jd_input.addEventListener('keyup', function () {
    //     if (this.value == '') {
    //         con.style.display = 'none'
    //     } else {
    //         con.style.display = 'block'
    //         con.innerHTML = this.value
    //     }
    // })
    // jd_input.addEventListener('blur', function () {
    //     con.style.display = 'none'
    // })
    // jd_input.addEventListener('focus', function () {
    //     if (this.value !== '') {//获得焦点时由内容才显示
    //         con.style.display = 'block'
    //         con.innerHTML = this.value
    //     } else {
    //         con.style.display = 'none'
    //     }
    // })
</script>
</body>

</html>